home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / news-text.scm < prev    next >
Encoding:
Text File  |  2009-08-19  |  3.3 KB  |  94 lines

  1. ; Newsprint text
  2. ; Copyright (c) 1998 Austin Donnelly <austin@greenend.org.uk>
  3. ;
  4. ;
  5. ; Based on alien glow code from Adrian Likins
  6. ;
  7. ; This program is free software: you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation; either version 3 of the License, or
  10. ; (at your option) any later version.
  11. ;
  12. ; This program is distributed in the hope that it will be useful,
  13. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ; GNU General Public License for more details.
  16. ;
  17. ; You should have received a copy of the GNU General Public License
  18. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  
  20.  
  21. (define (script-fu-newsprint-text string font font-size cell-size
  22.                                   density blur-radius text-color bg-color)
  23.   (let* (
  24.         (text-ext (gimp-text-get-extents-fontname string font-size PIXELS font))
  25.         (width (+ (car text-ext) 20 blur-radius))
  26.         (height (+ (list-ref text-ext 1) 20 blur-radius))
  27.         (img (car (gimp-image-new width height RGB)))
  28.         (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
  29.         (text-layer (car (gimp-layer-new img width height RGBA-IMAGE "Text layer" 100 NORMAL-MODE)))
  30.         (text-mask 0)
  31.         (grey (/ (* density 255) 100))
  32.         )
  33.  
  34.     (gimp-context-push)
  35.  
  36.     (gimp-image-undo-disable img)
  37.     (gimp-image-add-layer img bg-layer 1)
  38.     (gimp-image-add-layer img text-layer -1)
  39.  
  40.     (gimp-context-set-background bg-color)
  41.     (gimp-edit-clear bg-layer)
  42.     (gimp-edit-clear text-layer)
  43.  
  44.     (gimp-context-set-foreground text-color)
  45.     (gimp-floating-sel-anchor
  46.       (car (gimp-text-fontname img text-layer
  47.                                (/ (+ 20 blur-radius) 2) (/ (+ 20 blur-radius) 2)
  48.                                string 0 TRUE font-size PIXELS font)))
  49.  
  50.     (set! text-mask (car (gimp-layer-create-mask text-layer ADD-ALPHA-MASK)))
  51.     (gimp-layer-add-mask text-layer text-mask)
  52.  
  53.     (gimp-selection-layer-alpha text-layer)
  54.     (gimp-context-set-background (list grey grey grey))
  55.     (gimp-edit-fill text-mask BACKGROUND-FILL)
  56.     (gimp-selection-none img)
  57.     (if (> blur-radius 0)
  58.         (plug-in-gauss-iir RUN-NONINTERACTIVE img text-mask blur-radius 1 1)
  59.     )
  60.  
  61.     (plug-in-newsprint RUN-NONINTERACTIVE img text-mask cell-size
  62.                        0 0 45.0 3 45.0 0 45.0 0 45.0 0 3)
  63.  
  64.     (gimp-edit-fill text-layer FOREGROUND-FILL)
  65.     (gimp-layer-remove-mask text-layer MASK-APPLY)
  66.  
  67.     (gimp-image-undo-enable img)
  68.  
  69.     (gimp-display-new img)
  70.  
  71.     (gimp-context-pop)
  72.   )
  73. )
  74.  
  75. (script-fu-register "script-fu-newsprint-text"
  76.   _"Newsprint Te_xt..."
  77.   _"Create a logo in the style of newspaper printing"
  78.   "Austin Donnelly"
  79.   "Austin Donnelly"
  80.   "1998"
  81.   ""
  82.   SF-STRING     _"Text"               "Newsprint"
  83.   SF-FONT       _"Font"               "Sans"
  84.   SF-ADJUSTMENT _"Font size (pixels)" '(100 2 1000 1 10 0 1)
  85.   SF-ADJUSTMENT _"Cell size (pixels)" '(7 1 100 1 10 0 1)
  86.   SF-ADJUSTMENT _"Density (%)"        '(60 0 100 1 10 0 0)
  87.   SF-ADJUSTMENT _"Blur radius"        '(0 0 100 1 5 0 0)
  88.   SF-COLOR      _"Text color"         "black"
  89.   SF-COLOR      _"Background color"   "white"
  90. )
  91.  
  92. (script-fu-menu-register "script-fu-newsprint-text"
  93.                          "<Image>/File/Create/Logos")
  94.